// pages/thing/thingstorage.js
Page({
  mixins: [require('../mixin/themeChanged')],

  /**
   * 页面的初始数据
   */
  data: {
    city:"",
    thinglist:[],
    classone:[],
    classoneindex:""

  },

  bindClassoneChange:function(e){

    var that=this

    var url = wx.getStorageSync("config") 
  

    this.setData({
      classoneindex: e.detail.value,
    }) 

    wx.request({
      url: url.service.homeUrl + '/thing/getthingstorage',
      data: {
        city: that.data.city,
        classone:that.data.classone[that.data.classoneindex],
      },
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: (res) => {

        that.setData({
          thinglist: res.data,
        })


      },
      fail: function (res) {},
      complete: function (res) {},
    })

  },

  changeTheme: function() {
    console.log(this.data);
    getApp().themeChanged(this.data.theme === 'light' ? 'dark' : 'light');
},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    var that = this
    var url = wx.getStorageSync("config")

    this.setData({
      city: wx.getStorageSync('city')
    })  

  
    wx.request({
      url: url.service.homeUrl+'/thing/getclassone',
      data: {city:that.data.city,
           
            },
      // header: {
      //   Authorization: userInfo ? "token " + userInfo.token : ""
      // },
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: (res) => {
        for(var i=0;i<res.data.length;i++)
        { var newarray = [res.data[i].classone,];        
         that.data.classone = that.data.classone.concat(newarray);
         that.setData({
          classone: that.data.classone
        });  
      }},
      fail: function (res) { },
      complete: function (res) { },
    })


    


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})